﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XiaDaJH.aspx.cs" Inherits="Web.Pages.YongShui.JiHuaGL.XiaDaJH" Theme="Default" ValidateRequest="false" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../../../JS/jquery.js" type="text/javascript"></script>

    <script type="text/javascript">

        function XiaDaJH() {
            var chk1 = chkBenBu.GetChecked();
            var chk2 = chkBanShiChu.GetChecked();
            //alert(chk1);
            //alert(chk2);
            if (chk1 || chk2) {
                ASPxCallback1.PerformCallback("xdyz1");
            }
            else {
                alert("请先选择本部或者办事处下达计划！");
            }
        }

        function RunXDJH() {
            var chk1 = chkBenBu.GetChecked();
            var chk2=chkBanShiChu.GetChecked();
            if (chk1 && chk2) {
                ASPxCallback1.PerformCallback("xdjh_bb_bsc");
            }
            else if (chk1 && !chk2) {
                ASPxCallback1.PerformCallback("xdjh_bb");
            }
            else if (!chk1 && chk2) {
                ASPxCallback1.PerformCallback("xdjh_bsc");
            }
        }

        //LoadPanel.Show(); 
        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (type == "xdyz1") {
                if (arr[2] == '1') {
                    alert(txtNian.GetText() + "年计划未预编制,不允许此操作");
                }
                else {
                    ASPxCallback1.PerformCallback("xdyz2");
                }
            }
            else if (type == "xdyz2") {
                if (arr[2] == '1') {
                    if (confirm('计划用水量存在不合理数据，是否继续？')) {
                        RunXDJH();
                    }
                    else {
                        RunXDJH();
                    }
                }
            }
            else if (type == "xdjh_bb_bsc") {
                if (arr[2] == '1') {
                    alert('本部计划下达成功，办事处计划下达成功！');
                    txtXiaDaQK.SetText(txtNian.GetText() + '本部计划下达成功，办事处计划下达成功！');
                    chkBenBu.SetEnabled(false);
                    chkBanShiChu.SetEnabled(false);
                }
                else if (arr[2] == '2') {
                    alert('本部计划下达成功，办事处计划下达失败！');
                    txtXiaDaQK.SetText(txtNian.GetText() + '本部计划下达成功，办事处计划下达失败！');
                    chkBenBu.SetEnabled(false);
                    chkBanShiChu.SetEnabled(true);
                }
                else if (arr[2] == '3') {
                    alert('本部计划下达失败，办事处计划下达成功！');
                    txtXiaDaQK.SetText(txtNian.GetText() + '本部计划下达失败，办事处计划下达成功！');
                    chkBenBu.SetEnabled(true);
                    chkBanShiChu.SetEnabled(false);
                }
                else {
                    alert('下达失败！');
                    chkBenBu.SetEnabled(true);
                    chkBanShiChu.SetEnabled(true);
                }
            }
            else if (type == "xdjh_bb") {
                if (arr[2] == '1') {
                    alert('本部计划下达成功！');
                    txtXiaDaQK.SetText(txtNian.GetText() + '本部计划下达成功');
                    chkBenBu.SetEnabled(false);
                }
                else {
                    alert('本部计划下达失败！');
                }
            }
            else if (type == "xdjh_bsc") {
                if (arr[2] == '1') {
                    alert('办事处计划下达成功！');
                    txtXiaDaQK.SetText(txtNian.GetText() + '办事处计划下达成功！');
                    chkBanShiChu.SetEnabled(false);
                }
                else {
                    alert('办事处计划下达失败！');
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            下达计划
        </div>
         <div style="display: none;">
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        </div> 
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table style="width: 90%">
                    <tr>
                        <td style="white-space: nowrap; width: 1%">年：</td>
                        <td style="white-space: nowrap; width: 30%">
                            <dx:ASPxTextBox ID="txtNian" Width="40%" ClientInstanceName="txtNian" runat="server" ClientEnabled="false">
                             </dx:ASPxTextBox>
                        </td>
                        <td style="white-space: nowrap; width: 30%">
                            <dx:ASPxCheckBox Checked="false" ID="chkBenBu" runat="server" Text="下达本部计划" Width="80%" ClientInstanceName="chkBenBu"  ClientEnabled="false">
                            </dx:ASPxCheckBox>
                        </td>
                        <td style="white-space: nowrap; width: 30%">
                            <dx:ASPxCheckBox Checked="false" ID="chkBanShiChu" runat="server" Text="下达办事处计划" Width="80%" ClientInstanceName="chkBanShiChu" ClientEnabled="false">
                            </dx:ASPxCheckBox>
                        </td>
                    </tr>
                </table>
                <hr />
                <div>
                    <table style="width:100%;" align="center">
                        <tr>
                            <td style="width:20%; text-align:right;">计划下达情况：</td>
                            <td style="width:70%; text-align:left;">
                                <dx:ASPxTextBox ID="txtXiaDaQK" ClientInstanceName="txtXiaDaQK" Width="50%" runat="server" ClientEnabled="false">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                    </table>
                </div>
                <hr />
                <div>
                    <table style="width:100%;" align="center">
                        <tr>
                            <td rowspan="2" style="text-align:right;">
                                <div style="width: 40px; height: 40px; margin-right:40px;">
                                    <img src="../../../Images/js.png" style="width: 100%; height: 100%;" />

                                </div>
                            </td>
                            <td style="width: 100px;">提示：</td>
                            <td></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>您确认下达计划吗？</td>
                        </tr>
                    </table>
                </div>
                <hr />
                <div>
                    <table id="Table2" runat="server" style="width: 100%;text-align:center;">
                        <tr>
                            <td style="text-align: center;">
                                <dx:ASPxLoadingPanel runat="server" ID="LoadPanel11" ClientInstanceName="LoadPanel" Text="正在下达计划"></dx:ASPxLoadingPanel>
                                <dx:ASPxButton ID="btnXiaDaJH" runat="server" Text="下达计划"  UseSubmitBehavior="false" AutoPostBack="False">                                 
                                    <ClientSideEvents Click="function(s, e) { XiaDaJH();}" /> 
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </div>
                
            </ContentTemplate>
        </asp:UpdatePanel>

    </form>
</body>
</html>
